package com.sunny.ynhz.ui.ynts;

import android.graphics.Color;
import android.os.Bundle;

import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.Legend;
import com.github.mikephil.charting.components.LimitLine;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.components.YAxis;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import com.sunny.ynhz.R;
import com.sunny.ynhz.ui.base.AppBaseTranslationTitleBarActivity;
import com.sunny.ynhz.utils.ChartUtils;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by huhuan123 on 2018/8/10.
 *
 * @describe TODO
 */

public class TestMoreLineActivity extends AppBaseTranslationTitleBarActivity {
    private XAxis xAxis;                //X轴
    private YAxis leftYAxis;            //左侧Y轴
    private YAxis rightYaxis;           //右侧Y轴
    private Legend legend;              //图例
    private LimitLine limitLine;        //限制线
    //  private MyMarkerView markerView;    //标记视图 即点击xy轴交点时弹出展示信息的View
    @BindView(R.id.mlines)
    LineChart lineChart;
    List<Integer> mList = new ArrayList<>();
    List<Float> mList1 = new ArrayList<>();
    List<Float> mlist2 = new ArrayList<>();


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.test_more_line);
        ChartUtils.initChart(lineChart,this);
        initData();
//        ChartUtils.showLineChart(mList, "我的收益", Color.parseColor("#E2B25F"), lineChart);
//        ChartUtils.addLine(mList1, "上证指数", Color.parseColor("#6EE4A2"), lineChart);
//        ChartUtils.addLine(mlist2, "下证指数", Color.parseColor("#79C6EC"), lineChart);
    }

//    /**
//     * 添加曲线
//     */
//    private void addLine(List<Float> dataList, String name, int color) {
//        List<Entry> entries = new ArrayList<>();
//        for (int i = 0; i < dataList.size(); i++) {
//            Entry entry = new Entry(i,dataList.get(i));
//            entries.add(entry);
//        }
//        // 每一个LineDataSet代表一条线
//        LineDataSet lineDataSet = new LineDataSet(entries, name);
//        initLineDataSet(lineDataSet, color, LineDataSet.Mode.LINEAR);
//        lineChart.getLineData().addDataSet(lineDataSet);
//        lineChart.invalidate();
//    }


    public void initData() {
        for (int i = 1; i < 13; i++) {
            mList.add((int) (10 + Math.random() * (10 - 1)));
        }
        for (int i = 1; i < 13; i++) {
            mList1.add((float) (20 + Math.random() * (20 - 1)));
        }
        for (int i = 1; i < 13; i++) {
            mlist2.add((float) (30 + Math.random() * (30 - 1 + 10)));
        }
    }


}
